<?php
    include("./include.php");
	
	if(!$_SESSION[user_id]){
		?>
		<script>
			alert("로그인이 필요합니다");
			location.replace("board_login.php");
		</script>
		<?
	}
	
	$sql = "select * from tb_board where b_idx ='".$_GET[b_idx]."'";
	$result = sql_querry($sql);
	$data = mysql_fetch_array($result);
	
	if(!$data[b_idx]){
		?>
		<script>
			alert("존재하지 않는 글입니다.");
		</script>
		<?
	}
	
	if($data[m_id] != $_SESSION[user_id]){
		?>
		<script>
			alert("본인의 글이 아닙니다.");
			history.back();
		</script>
		<?
	}
	
	$sql_delete = "delete from tb_board where b_num = '".$data[b_num]."' and b_reply like '".$data[b_reply]."%'";
	sql_querry($sql_delete);
?>
<script>
	alert("글이 삭제 되었습니다.");
	location.replace("./board_list.php");
</script>